$(function () {
    // 粒子线条背景
    $(document).ready(function () {
        $('.layui-container').particleground({
            dotColor: '#7ec7fd',
            lineColor: '#7ec7fd'
        })
    })


    // 登录操作
    let layer;
    let form;
    layui.use(['layer', 'form'], function () {
        layer = layui.layer;
        form = layui.form;




        $('.admin-login-background form').on('submit', function (e) {
            //阻止默认行为
            e.preventDefault()

            //收集数据
            let data = $(this).serialize()

            //提交数据
            $.ajax({
                url: '/api/login',
                type: 'POST',
                data: data,
                success: function (res) {
                    // console.log(res);
                    layer.msg(res.message)
                    if (res.status == 0) {
                        location.href = '/index.html'
                        localStorage.setItem('mytoken', res.token)
                    }
                }
            })
        })


    })

})